﻿using UnityEditor;
using UnityEngine;

public static class CothCommands
{
    [MenuItem("CONTEXT/Cloth/Skinn: Max Distance To Zero" , false, 1)]
    private static void MaxDistanceToZero(MenuCommand command)
    {
        var context = (Cloth)command.context;

        var coefficients = context.coefficients;

        if (coefficients == null) return;

        Undo.RecordObject(context, "Max Distance To Zero");

        for (int i = 0; i < coefficients.Length; i++)
        {
            coefficients[i].maxDistance = 0f;
        }

        context.coefficients = coefficients;
    }

    [MenuItem("CONTEXT/Cloth/Skinn: Max Distance To One", false, 1)]
    private static void MaxDistanceToOne(MenuCommand command)
    {
        var context = (Cloth)command.context;

        var coefficients = context.coefficients;

        if (coefficients == null) return;

        Undo.RecordObject(context, "Max Distance To One");

        for (int i = 0; i < coefficients.Length; i++)
        {
            coefficients[i].maxDistance = 1f;
        }

        context.coefficients = coefficients;
    }

    [MenuItem("CONTEXT/Cloth/Skinn: Collision Distance To Zero", false, 1)]
    private static void CollisionDistanceToZero(MenuCommand command)
    {
        var context = (Cloth)command.context;

        var coefficients = context.coefficients;

        if (coefficients == null) return;

        Undo.RecordObject(context, "Collision Distance To Zero");

        for (int i = 0; i < coefficients.Length; i++)
        {
            coefficients[i].collisionSphereDistance = 0f;
        }

        context.coefficients = coefficients;
    }

    [MenuItem("CONTEXT/Cloth/Skinn: Collision Distance To One", false, 1)]
    private static void CollisionDistanceToOne(MenuCommand command)
    {
        var context = (Cloth)command.context;

        var coefficients = context.coefficients;

        if (coefficients == null) return;

        Undo.RecordObject(context, "Collision Distance To One");

        for (int i = 0; i < coefficients.Length; i++)
        {
            coefficients[i].collisionSphereDistance = 1f;
        }

        context.coefficients = coefficients;
    }
}
